<?php

class ShareModel extends RelationModel{
    public $_link = array(
        'User'=>array(
                'mapping_type' =>BELONGS_TO,
                    'class_name'=>'User',
                    'foreign_key'=>'userid',
                    'mapping_name'=>'user',
        ),
        'BaseBrand'=>array(
                'mapping_type' =>BELONGS_TO,
                    'class_name'=>'BaseBrand',
                    'foreign_key'=>'brand_id',
                    'mapping_name'=>'brand',
        ),
        'BaseCategory'=>array(
                'mapping_type' =>BELONGS_TO,
                    'class_name'=>'BaseCategory',
                    'foreign_key'=>'category_id',
                    'mapping_name'=>'category',
        ),
        'BaseCommodity'=>array(
                'mapping_type' =>BELONGS_TO,
                    'class_name'=>'BaseCommodity',
                    'foreign_key'=>'commodity_id',
                    'mapping_name'=>'commodity',
        ),
    );

    public function addBrand(){
    	$data['add_time'] = time();
    	$data['name'] = $_REQUEST['brand'];
    	$data['industry_id'] = $_REQUEST['industry_id'];
    	$data['py'] = $_REQUEST['py'];
    	$result = M("BaseBrand")->data($data)->add();
    	return $result;
    }
    public function addCategory(){
    	$data['add_time'] = time();
    	$data['name'] = $_REQUEST['category'];
    	$data['industry_id'] = $_REQUEST['industry_id'];
    	$data['py'] = $_REQUEST['py'];
    	$result = M("BaseCategory")->data($data)->add();
    	return $result;
    }
    public function addCommodity($sp_info){
    	$data['add_time'] = time();
    	$data['name'] = $_REQUEST['commodity'];
    	$data['industry_id'] = $_REQUEST['industry_id'];
    	$data['brand_id'] = $sp_info['brand_id'];
    	$data['category_id'] = $sp_info['category_id'];
    	$data['py'] = $_REQUEST['py'];
    	$result = M("BaseCommodity")->data($data)->add();
    	return $result;
    }
    
    
    
    
    
    

    
}
?>
